#include "mainwindow.h"
#include <QApplication>
#include <QLabel>
#include <QPointer>
#include <QDebug>
#include <QScopedPointer>

#include <QGraphicsScene>
#include <QGraphicsView>

#include <QTextCodec>

void test_nomal()
{
    QLabel * lab = new QLabel();  QPointer<QLabel> pLabel = new QLabel() ;
    lab->resize(200,200);
    lab->show();

    delete lab;

    qDebug() << ((lab != nullptr) ? "lab != nullptr" : "lab == nullptr");

}
void test_QPointer()
{
    QPointer<QLabel> lab = new QLabel();
    lab->resize(200,200);
    lab->show();

    delete lab;

    qDebug() << ((lab != nullptr) ? "lab != nullptr" : "lab == nullptr");

}

void test_QScopePointer()
{
    {
        QScopedPointer<QLabel> lab (new QLabel());
        lab->resize(200,200);
        lab->show();
    }
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    a.setFont(QFont("Microsoft Yahei", 9));

#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
#if _MSC_VER
    QTextCodec *codec = QTextCodec::codecForName("gbk");
#else
    QTextCodec *codec = QTextCodec::codecForName("utf-8");
#endif
    QTextCodec::setCodecForLocale(codec);
    QTextCodec::setCodecForCStrings(codec);
    QTextCodec::setCodecForTr(codec);
#else
    QTextCodec *codec = QTextCodec::codecForName("gbk");
    QTextCodec::setCodecForLocale(codec);
#endif

    MainWindow w;
    w.show();

    return a.exec();
}
